#include <iostream>
#include <string>
#include <cmath>
using namespace std;
typedef long long LL;
#define endl '\n'
void solve() 
{
    string s; cin >> s;
    int t = stoi(s);
    int sq = sqrt(t);
    if(sq * sq != t) cout << -1 << endl;
    else 
    {
        cout << 0 << " " << sq << endl;
    }
}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int T;
	cin >> T;
	while(T--)
	{
        solve();
	}
	return 0;
}